package com.bjpowernode.javase.collection.treesetTest;

import java.util.Objects;

public class Account implements Comparable<Account>{
    private Integer no;
    private String name;
    private Integer age;
    private Integer isDefault;

    public Account(){}

    public Account(Integer no, String name, Integer age, Integer isDefault) {
        this.no = no;
        this.name = name;
        this.age = age;
        this.isDefault = isDefault;
    }

    @Override
    public int compareTo(Account o) {
        /*if (this.isDefault.equals(o.isDefault)){
            return o.getNo() - this.no;
        }else {
            return o.getIsDefault() - this.getIsDefault();
        }*/
        return o.getIsDefault() - this.getIsDefault();
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Account account = (Account) o;
        return name.equals(account.name) && age.equals(account.age);
    }

    @Override
    public int hashCode() {
        return Objects.hash(name, age);
    }

    public Integer getNo() {
        return no;
    }

    public void setNo(Integer no) {
        this.no = no;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Integer getAge() {
        return age;
    }

    public void setAge(Integer age) {
        this.age = age;
    }

    public Integer getIsDefault() {
        return isDefault;
    }

    public void setIsDefault(Integer isDefault) {
        this.isDefault = isDefault;
    }

    @Override
    public String toString() {
        return "Account{" +
                "no=" + no +
                ", name='" + name + '\'' +
                ", age=" + age +
                ", isDefault=" + isDefault +
                '}';
    }
}
